<template>
    <div id="withdraw-list">
        <van-pull-refresh v-model="refreshing" @refresh="onRefresh()">
            <van-list v-model:loading="loading" :finished="finished" :offset="100" finished-text="没有更多了" @load="loadData()" class="con-wrap">
                <div class="withdraw-item" v-for="item in withdrawList" :key="item.id" @click="toDetial(item.id)">
                    <div class="flex-nowrap">
                        <div class="withdraw-left">
                            <p class="color_6">提现单号：</p>
                            <p class="color_6">提现金额：</p>
                            <p class="color_6">手续费：</p>
                            <p class="color_6">到账银行：</p>
                            <p class="color_6">申请时间：</p>
                        </div>
                        <div class="withdraw-right">
                            <p>{{ item.order_sn }}</p>
                            <p class="color-main">￥{{ item.money }}</p>
                            <p class="color-red">￥{{ item.handing_fee }}</p>
                            <p>{{ item.user_account }}</p>
                            <p>{{ item.created_at }}</p>
                        </div>
                    </div>
                    <div class="withdraw-status">
                        <p class="color-main">{{ item.active_text }}</p>
                    </div>
                </div>
            </van-list>
        </van-pull-refresh>
    </div>
</template>


<script>
export default {
    name: 'WithdrawList',
    data() {
        return {
            onLoad:false,
            loading:false,
            finished:false,
            refreshing: false,
            pages:{
                page:0,
                size:10,
            },
            withdrawList:[],
        }
    },
    created() {
        this.onRefresh();
    },
    methods: {
        // 上拉
        loadData() {
            let self = this;
            if (self.refreshing) {
                self.refreshing = false;
            }
            self.loading = true;
            self.finished = false
            self.$api.withdraw.list({page: self.pages.page,size: self.pages.size}).then(res => {
                let data = self.pages.page == 1 ? [] : self.withdrawList;
                for( var i = 0; i< res.result.length; i ++) {
                    data.push(res.result[i]);
                }
                self.withdrawList = data;
                self.pages.page++;
                self.loading = false;
                if (res.result.length < 10) {
                    self.finished = true;
                }
            }).finally(e =>{});
        },
        // 下拉刷新
        onRefresh() {
            // 清空列表数据
            this.finished = false;
            this.loading = true;
            this.refreshing = true;
            this.pages.page = 1;
            this.loadData();
        },
        toDetial(id){
            this.$router.push('/withdraw/success/' + id);
        }
    }
}
</script>
